Hello guys.
This article is the sixth part of this article series. This will talk about string, its related operations, functioning in detail by using several examples and graphics. So let’s explore it.
Getting Theme
For getting the theme of Python, kindly go through my previous articles:
- Diving Into Python: Chapter 1
- Diving Into Python: Chapter 2
- Diving Into Python: Chapter 3
- Diving Into Python: Chapter 4
- Diving Into Python: Chapter 5
Strings Manipulation
Now I will talk about string manipulation in Python. So, since we already know about string manipulation (being programmers) I will not explain it in detail. I will just show how easily you can do that in Python.
Expressing a String
Strings | Single Quotes
You can manipulate a string using single quotes.
For Example
‘Goodbye World!’ # using Single quotes
Snippet: print(‘Goodbye World!’)
Strings | Double Quotes
Here’s an alternate way of achieving the same functionality, declaring it in double-quotes.
For Example
‘Oops! I think I made a mistake. I meant “Hello World!”.’ # using Double quote

It can be expressed in several ways in Python.
Snippet: print(‘Oops! I think I made a mistake. I meant “Hello World!”.’)
Or
‘I meant- “Hello World!”. ’
Snippet: print(‘I meant- “Hello World!”. ’)
String Concatenation
In general programming terms:
“Adding two strings is defined as String Concatenation.”
Approach 1
It can be done in the same way, as we do in some other programming language using a ‘+’ operator.
For Example
‘Being’ + ‘Programmer!’
‘BiengProgrammer!’
Approach 2
Now, let’s have a look at the second approach. Two or more string literals can also be concatenated automatically by writing them next to each other.
For Example
‘Being’ ‘Programmer!’
‘BiengProgrammer!’
String Repetition
Its name says it all. So I will only explain how to do that rather than explaining what it is. So let’s have a look.
For Example
‘M’ + 2 * ‘iss’ + ‘ppi’
‘Mississippi’
(I love this word, maybe because of Permutation & Combination and Probability Theory.)
I hope you guys now understand the theme. Let me explain this with an example.
As you guys can see, I used a ‘*’ operator just before the string ‘iss’ and you can see what we got. So string repetition works in this fashion using the ‘*’ operator.
Let’s have a look at one more example for a better understanding.
For Example:
‘Ba’ + 2 * ‘na’
‘Banana’
(I hope you guys can easily digest this example and the concept as well.)
PinPoints


NitinPosted May 14, 2015, 12:47 PM
nice one
Abhishek JaiswalPosted May 14, 2015, 8:38 AM
Aah, thanks!! :)
Gopi ChandPosted May 14, 2015, 8:37 AM
Nicely explained..Good
Abhishek JaiswalPosted May 14, 2015, 6:16 AM
Glad, you find this series useful! :)
vanama saishanthanPosted May 14, 2015, 4:33 AM
This is a good article please continue with remaining parts in this series.
Santhakumar MunuswamyPosted May 14, 2015, 1:08 AM
good work